package com.wm.web.action;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.SessionAware;

import com.wm.bean.Area;
import com.wm.bean.City;
import com.wm.bean.Scriptorium;
import com.wm.comm.Constant;
import com.wm.comm.PinYinUtil;
import com.wm.service.ApplyRestaurantService;
import com.wm.service.AreaService;
import com.wm.service.CityService;
import com.wm.service.ScriptoriumService;
import com.wm.service.web.PageList;
import com.wm.service.web.Pages;
import com.wm.web.ui.OptionsInt;
import com.wm.web.ui.OptionsLong;

public class AdminApplyRestaurant extends BaseAction{
	private static final Log logger = LogFactory.getLog(AdminApplyRestaurant.class);
	
	private ApplyRestaurantService applyRestaurantService;

	public ApplyRestaurantService getApplyRestaurantService() {
		return applyRestaurantService;
	}

	public void setApplyRestaurantService(
			ApplyRestaurantService applyRestaurantService) {
		this.applyRestaurantService = applyRestaurantService;
	}

	private List applyTypeList = new ArrayList();

	public List getApplyTypeList() {
		return applyTypeList;
	}

	public void setApplyTypeList(List applyTypeList) {
		this.applyTypeList = applyTypeList;
	}
	
	private void setApplyTypeListValues(){
		applyTypeList.add(new OptionsInt(-1, "请选择"));
		
	}
	
	private void listInitValues(){
		setApplyTypeListValues();
	}

	private int applyType = -1;			//类型

	public int getApplyType() {
		return applyType;
	}

	public void setApplyType(int applyType) {
		this.applyType = applyType;
	}

	private PageList pageList;


	public PageList getPageList() {
		return pageList;
	}

	public void setPageList(PageList pageList) {
		this.pageList = pageList;
	}	

	public String execute() {
		try {
			return this.executeMethod(this.getAction());
		} catch (Exception e) {
			logger.error(e);
			return INPUT;
		}
	}

	/**
	 * 初始页
	 */
	public String index(){
		return null;
	}	
	/**
	 * 弹出
	 */
	public String pop(){
		listInitValues();
		Pages pages = new Pages();
		pages.setPage(this.getPage());
		pages.setPerPageNum(Constant.PAGE_NUM);
		if (this.getTotal() > 0) {
			pages.setTotalNum(this.getTotal());
		}
		pages.setFileName("/admin_apply_restaurant.action?action=pop&applyType=" + this.applyType);
		this.setPageList(this.getApplyRestaurantService().findApplyRestaurants(applyType,"id", 1, pages));
		return "pop";
	}

}
